com.flagstone.transform.fillstyle
Class MorphGradient

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

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

MorphGradient defines the control points that is used to specify how a gradient fill is displayed at the start and end of the shape morphing process.

The ratio is a number between 0 and 255 - that specifies the relative location in the square. For Linear Gradient Fills a ratio of zero is mapped to the left side of the gradient square and 255 is mapped to the right side of the square. For Radial Gradient Fills a ratio of zero is mapped to the centre of the gradient square and 255 is mapped to the edge of the largest circle that fits inside the gradient square. The color is the colour to be displayed at the point identified by the ratio.

The MorphGradient defines ratios and colours for the start and end of the morphing process, the Flash Player performs the interpolation between the two values as the shape is morphed.

See Also:
Gradient, GradientFill, MorphGradientFill

Constructor Summary
MorphGradient(Gradient startGradient, Gradient endGradient)
          Creates a MorphGradient object specifying the starting and ending gradients.
MorphGradient(MorphGradient object)
          Creates and initialises a MorphGradient object using the values copied from another MorphGradient object.
MorphGradient(SWFDecoder coder, Context context)
          Creates and initialises a MorphGradient object using values encoded in the Flash binary format.
 
Method Summary
 MorphGradient copy()
          Creates a complete copy of this object.
 void encode(SWFEncoder coder, Context context)
          Encode an object to the Flash binary format.
 Gradient getEnd()
          Get the gradient containing the ratio and colour at the end of the morphing process.
 Gradient getStart()
          Get the gradient containing the ratio and colour 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 setEnd(Gradient gradient)
          Sets the gradient at the end of the morphing process.
 void setStart(Gradient gradient)
          Sets the gradient 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

MorphGradient

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

MorphGradient

public MorphGradient(Gradient startGradient,
                     Gradient endGradient)
Creates a MorphGradient object specifying the starting and ending gradients.

Parameters:
startGradient - the Gradient containing the initial ratio and colour.
endGradient - the Gradient containing the final ratio and colour.

MorphGradient

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

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

getStart

public Gradient getStart()
Get the gradient containing the ratio and colour at the start of the morphing process.

Returns:
the starting gradient.

getEnd

public Gradient getEnd()
Get the gradient containing the ratio and colour at the end of the morphing process.

Returns:
the final gradient.

setStart

public void setStart(Gradient gradient)
Sets the gradient at the start of the morphing process.

Parameters:
gradient - the Gradient containing the ratio and colour at the start of the morphing process.

setEnd

public void setEnd(Gradient gradient)
Sets the gradient at the end of the morphing process.

Parameters:
gradient - the Gradient containing the ratio and colour at the end of the morphing process.

copy

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

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