com.flagstone.transform.shape
Class DefineMorphShape2

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

public final class DefineMorphShape2
extends Object
implements ShapeTag

DefineMorphShape2 defines a shape that will morph from one form into another. It extends the functionality of DefineMorphShape by using LineStyle2 objects rather than LineStyle1.

Only the start and end shapes are defined the Flash Player will perform the interpolation that transforms the shape at each staging in the morphing process.

Morphing can be applied to any shape, however there are a few restrictions:

To perform the morphing of a shape the shape is placed in the display list using a PlaceObject2 object. The ratio attribute in the PlaceObject2 object defines the progress of the morphing process. The ratio ranges between 0 and 65535 where 0 represents the start of the morphing process and 65535, the end.

The edges in the shapes may change their type when a shape is morphed. Straight edges can become curves and vice versa.


Constructor Summary
DefineMorphShape2(DefineMorphShape2 object)
          Creates and initialises a DefineMorphShape2 object using the values copied from another DefineMorphShape2 object.
DefineMorphShape2(int uid, Bounds startRect, Bounds endRect, List<FillStyle> fills, List<LineStyle> lines, Shape initialShape, Shape finalShape)
          Creates a DefineMorphShape object.
DefineMorphShape2(SWFDecoder coder, Context context)
          Creates and initialises a DefineMorphShape2 object using values encoded in the Flash binary format.
 
Method Summary
 DefineMorphShape2 add(FillStyle aFillStyle)
          Add the fill style object to the list of fill styles.
 DefineMorphShape2 add(LineStyle style)
          Add a LineStyle object to the list of line styles.
 DefineMorphShape2 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 Bounds object that defines the bounding rectangle enclosing the start shape.
 Bounds getEdgeBounds()
          Get the Bounds object that defines the bounding rectangle enclosing the starting shape, excluding the width of the lines used.
 Bounds getEndBounds()
          Get the Bounds object that defines the bounding rectangle enclosing the end shape.
 Bounds getEndEdgeBounds()
          Get the Bounds object that defines the bounding rectangle enclosing the end shape, excluding the width of the lines used.
 Shape getEndShape()
          Get shape displayed at the end of the morphing process.
 List<FillStyle> getFillStyles()
          Returns the list of fill styles (MorphSolidFill, MorphBitmapFill and MorphGradientFill objects) for the shapes.
 int getIdentifier()
          Get the unique identifier assigned to this object.
 List<LineStyle> getLineStyles()
          Get the list of line styles (MorphLineStyle2 objects) for the shapes.
 Shape getShape()
          Get shape displayed at the start of the morphing process.
 int prepareToEncode(Context context)
          Prepare an object for encoding, returning the expected size of an object when it is encoded.
 void setBounds(Bounds rect)
          Sets the starting bounds of the shape.
 void setEdgeBounds(Bounds rect)
          Sets the starting bounds of the shape.
 void setEndBounds(Bounds rect)
          Sets the ending bounds of the shape.
 void setEndEdgeBounds(Bounds rect)
          Sets the ending bounds of the shape.
 void setEndShape(Shape aShape)
          Sets the shape that will be displayed at the end of the morphing process.
 void setFillStyles(List<FillStyle> list)
          Sets the list of morph fill styles.
 void setIdentifier(int uid)
          Sets the unique identifier for an object within a given Movie.
 void setLineStyles(List<LineStyle> list)
          Sets the list of morph line styles.
 void setShape(Shape aShape)
          Sets the shape that will be displayed at the start of the morphing process.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DefineMorphShape2

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

DefineMorphShape2

public DefineMorphShape2(int uid,
                         Bounds startRect,
                         Bounds endRect,
                         List<FillStyle> fills,
                         List<LineStyle> lines,
                         Shape initialShape,
                         Shape finalShape)
Creates a DefineMorphShape object.

Parameters:
uid - an unique identifier for this object. Must be in the range 1..65535.
startRect - the bounding rectangle enclosing the start shape. Must not be null.
endRect - the bounding rectangle enclosing the end shape. Must not be null.
fills - a list of MorphSolidFill, MorphBitmapFill and MorphGradientFill objects. Must not be null.
lines - a list of MorphLineStyle objects. Must not be null.
initialShape - the shape at the start of the morphing process. Must not be null.
finalShape - the shape at the end of the morphing process. Must not be null.

DefineMorphShape2

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

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

getIdentifier

public int getIdentifier()
Get the unique identifier assigned to this object.

Specified by:
getIdentifier in interface DefineTag
Returns:
the unique identifier used by the Flash Player to reference this definition.

setIdentifier

public void setIdentifier(int uid)
Sets the unique identifier for an object within a given Movie.

Specified by:
setIdentifier in interface DefineTag
Parameters:
uid - a unique identifier for the object. Must be in the range 1..65535.

add

public DefineMorphShape2 add(LineStyle style)
Add a LineStyle object to the list of line styles.

Specified by:
add in interface ShapeTag
Parameters:
style - a MorphLineStyle2 object. Must not be null. Must be an instance of MorphLineStyle2.
Returns:
this object.

add

public DefineMorphShape2 add(FillStyle aFillStyle)
Add the fill style object to the list of fill styles.

Specified by:
add in interface ShapeTag
Parameters:
aFillStyle - an FillStyle object. Must not be null.
Returns:
this object.

getBounds

public Bounds getBounds()
Get the Bounds object that defines the bounding rectangle enclosing the start shape.

Specified by:
getBounds in interface ShapeTag
Returns:
the bounding box for the starting shape.

getEndBounds

public Bounds getEndBounds()
Get the Bounds object that defines the bounding rectangle enclosing the end shape.

Returns:
the bounding box for the final shape.

getEdgeBounds

public Bounds getEdgeBounds()
Get the Bounds object that defines the bounding rectangle enclosing the starting shape, excluding the width of the lines used.

Returns:
the bound box for the outline of the initial shape.

getEndEdgeBounds

public Bounds getEndEdgeBounds()
Get the Bounds object that defines the bounding rectangle enclosing the end shape, excluding the width of the lines used.

Returns:
the bound box for the outline of the final shape.

getFillStyles

public List<FillStyle> getFillStyles()
Returns the list of fill styles (MorphSolidFill, MorphBitmapFill and MorphGradientFill objects) for the shapes.

Specified by:
getFillStyles in interface ShapeTag
Returns:
the list of fill styles used in the shape.

getLineStyles

public List<LineStyle> getLineStyles()
Get the list of line styles (MorphLineStyle2 objects) for the shapes.

Specified by:
getLineStyles in interface ShapeTag
Returns:
the list of line styles used in the shape.

getShape

public Shape getShape()
Get shape displayed at the start of the morphing process.

Specified by:
getShape in interface ShapeTag
Returns:
the starting shape.

getEndShape

public Shape getEndShape()
Get shape displayed at the end of the morphing process.

Returns:
the final shape.

setBounds

public void setBounds(Bounds rect)
Sets the starting bounds of the shape.

Specified by:
setBounds in interface ShapeTag
Parameters:
rect - the bounding rectangle enclosing the start shape. Must not be null.

setEndBounds

public void setEndBounds(Bounds rect)
Sets the ending bounds of the shape.

Parameters:
rect - the bounding rectangle enclosing the end shape. Must not be null.

setEdgeBounds

public void setEdgeBounds(Bounds rect)
Sets the starting bounds of the shape.

Parameters:
rect - the bounding rectangle enclosing the start shape. Must not be null.

setEndEdgeBounds

public void setEndEdgeBounds(Bounds rect)
Sets the ending bounds of the shape.

Parameters:
rect - the bounding rectangle enclosing the end shape. Must not be null.

setFillStyles

public void setFillStyles(List<FillStyle> list)
Sets the list of morph fill styles.

Specified by:
setFillStyles in interface ShapeTag
Parameters:
list - a list of MorphSolidFill, MorphBitmapFill and MorphGradientFill objects. Must not be null.

setLineStyles

public void setLineStyles(List<LineStyle> list)
Sets the list of morph line styles.

Specified by:
setLineStyles in interface ShapeTag
Parameters:
list - a list of MorphLineStyle2 objects. Must not be null.

setShape

public void setShape(Shape aShape)
Sets the shape that will be displayed at the start of the morphing process.

Specified by:
setShape in interface ShapeTag
Parameters:
aShape - the shape at the start of the morphing process. Must not be null.

setEndShape

public void setEndShape(Shape aShape)
Sets the shape that will be displayed at the end of the morphing process.

Parameters:
aShape - the shape at the end of the morphing process. Must not be null.

copy

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