com.flagstone.transform
Class Place

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

public final class Place
extends Object
implements MovieTag

PlaceObject is used to add an object (shape, button, etc.) to the Flash Player's display list.

When adding an object to the display list a coordinate transform can be applied to the object. This is principally used to specify the location of the object when it is drawn on the screen however more complex coordinate transforms can also be specified such as rotating or scaling the object without changing the original definition.

Similarly the color transform allows the color of the object to be changed when it is displayed without changing the original definition. The PlaceObject class only supports opaque colours so although the ColorTransform supports transparent colours this information is ignored by the Flash Player. The colour transform is optional and may be set to null, reducing the size of the PlaceObject instruction when it is encoded.

See Also:
Place2, Remove, Remove2

Constructor Summary
Place(int uid, int level, CoordTransform position)
          Creates a PlaceObject object that places the the object with the identifier at the specified layer and at the position specified by the coordinate transform.
Place(int uid, int level, CoordTransform matrix, ColorTransform cxform)
          Creates a PlaceObject object that places the the object with the identifier at the specified layer, coordinate transform and colour transform.
Place(Place object)
          Creates and initialises a Place object using the values copied from another Place object.
Place(SWFDecoder coder, Context context)
          Creates and initialises a Place object using values encoded in the Flash binary format.
 
Method Summary
 Place copy()
          Creates a complete copy of this object.
 void encode(SWFEncoder coder, Context context)
          Encode an object to the Flash binary format.
 ColorTransform getColorTransform()
          Get the colour transform.
 int getIdentifier()
          Get the identifier of the object to be placed.
 int getLayer()
          Get the Layer on which the object will be displayed in the display list.
 CoordTransform getTransform()
          Get the coordinate transform.
 int prepareToEncode(Context context)
          Prepare an object for encoding, returning the expected size of an object when it is encoded.
 Place setColorTransform(ColorTransform cxform)
          Sets the colour transform that defines any colour effects applied when the object is displayed.
 Place setIdentifier(int uid)
          Sets the identifier of the object that will be added to the display list.
 Place setLayer(int aNumber)
          Sets the layer that defines the order in which objects are displayed.
 Place setLocation(int xCoord, int yCoord)
          Sets the location where the object will be displayed.
 Place setTransform(CoordTransform matrix)
          Sets the transform that defines the position where the object is displayed.
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Place

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

Place

public Place(int uid,
             int level,
             CoordTransform position)
Creates a PlaceObject object that places the the object with the identifier at the specified layer and at the position specified by the coordinate transform.

Parameters:
uid - the unique identifier for the object to the placed on the display list. Must be in the range 1..65535.
level - the layer in the display list where the object will be placed.
position - an CoordTransform object that defines the orientation, size and location of the object when it is drawn. Must not be null.

Place

public Place(int uid,
             int level,
             CoordTransform matrix,
             ColorTransform cxform)
Creates a PlaceObject object that places the the object with the identifier at the specified layer, coordinate transform and colour transform.

Parameters:
uid - the unique identifier for the object to the placed on the display list. Must be in the range 1..65535.
level - the layer in the display list where the object will be placed.
matrix - an CoordTransform object that defines the orientation, size and location of the object when it is drawn. Must not be null.
cxform - an ColorTransform object that defines the colour of the object when it is drawn.

Place

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

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

getIdentifier

public int getIdentifier()
Get the identifier of the object to be placed. This is only required when placing an object for the first time. Subsequent references to the object on this layer can simply use the layer number.

Returns:
the unique identifier of the object to be displayed.

setIdentifier

public Place setIdentifier(int uid)
Sets the identifier of the object that will be added to the display list.

Parameters:
uid - the unique identifier for the object to the placed on the display list. Must be in the range 1..65535.
Returns:
this object.

getLayer

public int getLayer()
Get the Layer on which the object will be displayed in the display list.

Returns:
the layer where the object will be displayed.

setLayer

public Place setLayer(int aNumber)
Sets the layer that defines the order in which objects are displayed.

Parameters:
aNumber - the layer in the display list where the object will be placed. Must be in the range 1..65535.
Returns:
this object.

getTransform

public CoordTransform getTransform()
Get the coordinate transform. May be null if no coordinate transform was defined.

Returns:
the coordinate transform that will be applied to the displayed object.

setTransform

public Place setTransform(CoordTransform matrix)
Sets the transform that defines the position where the object is displayed.

Parameters:
matrix - an CoordTransform object that defines the orientation, size and location of the object when it is drawn. Must not be null.
Returns:
this object.

getColorTransform

public ColorTransform getColorTransform()
Get the colour transform. May be null if no colour transform was defined.

Returns:
the colour transform that will be applied to the displayed object.

setLocation

public Place setLocation(int xCoord,
                         int yCoord)
Sets the location where the object will be displayed.

Parameters:
xCoord - the x-coordinate of the object's origin.
yCoord - the x-coordinate of the object's origin.
Returns:
this object.

setColorTransform

public Place setColorTransform(ColorTransform cxform)
Sets the colour transform that defines any colour effects applied when the object is displayed.

Parameters:
cxform - an ColorTransform object that defines the colour of the object when it is drawn. May be set to null.
Returns:
this object.

copy

public Place 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.