com.flagstone.transform
Class ScalingGrid

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

public final class ScalingGrid
extends Object
implements DefineTag

ScalingGrid is used to define a 9-slice grid that can be used to control the way an object is scaled. The Bounds defines the central square of the grid. The (two) squares above and below the Bounds are scaled horizontally; the (two) squares to the left and right are scaled vertically and the (four) corner squares are not scaled at all.


Constructor Summary
ScalingGrid(int uid, Bounds rect)
          Creates and initialises a ScalingGrid with the specified object identifier and bounding box for the centre section.
ScalingGrid(ScalingGrid object)
          Creates and initialises a ScalingGrid object using the values copied from another ScalingGrid object.
ScalingGrid(SWFDecoder coder)
          Creates and initialises a ScalingGrid object using values encoded in the Flash binary format.
 
Method Summary
 ScalingGrid copy()
          Creates a complete copy of this object.
 void encode(SWFEncoder coder, Context context)
          Encode an object to the Flash binary format.
 Bounds getBounds()
          Get the bounding box that defined the centre section of the scaling grid.
 int getIdentifier()
          Get the identifier of the object which the scaling grid will be applied to.
 int prepareToEncode(Context context)
          Prepare an object for encoding, returning the expected size of an object when it is encoded.
 void setBounds(Bounds rect)
          Set the bounding box that defined the centre section of the scaling grid.
 void setIdentifier(int uid)
          Set the identifier of the object which the scaling grid will be applied to.
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ScalingGrid

public ScalingGrid(SWFDecoder coder)
            throws IOException
Creates and initialises a ScalingGrid object using values encoded in the Flash binary format.

Parameters:
coder - an SWFDecoder object that contains the encoded Flash data.
Throws:
IOException - if an error occurs while decoding the data.

ScalingGrid

public ScalingGrid(int uid,
                   Bounds rect)
Creates and initialises a ScalingGrid with the specified object identifier and bounding box for the centre section.

Parameters:
uid - the unique identifier of the object to which the grid will be applied
rect - the bounding box that defines the coordinates of the centre section of the grid.

ScalingGrid

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

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

getIdentifier

public int getIdentifier()
Get the identifier of the object which the scaling grid will be applied to.

Specified by:
getIdentifier in interface DefineTag
Returns:
the object identifier.

setIdentifier

public void setIdentifier(int uid)
Set the identifier of the object which the scaling grid will be applied to.

Specified by:
setIdentifier in interface DefineTag
Parameters:
uid - the unique identifier of the object.

getBounds

public Bounds getBounds()
Get the bounding box that defined the centre section of the scaling grid.

Returns:
the box defining the centre of the grid.

setBounds

public void setBounds(Bounds rect)
Set the bounding box that defined the centre section of the scaling grid.

Parameters:
rect - the box defining the centre of the grid.

copy

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